<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>考核</title>
	</head>
	<body>
	
		
		<!-- 
		 1.
		 if(false){
		     var a = 1;
		     let b = 2;
		 }
		 console.log(a);
		 console.log(b); 
		
		答:   undefined  报错
		
		2.
		var a = 1;
		if(true){
		    console.log(a);
		    let a = 2;
		}
		
		3.
		var a = {n: 1}
		var b = a
		a.x = a = {n: 2}
		
		
		console.log(a.x,b.x);
		console.log(a.n,b.n);
		4.
		 console.log(c);
		 var c;
		 function c(a) {
		     console.log(a);
		     var a = 3;
		     function a(){
		     }
		 }
		 c(2);
		 
		 
		 5.
		 var c = 1;
		 function c(c) {
		     console.log(c);
		     var c = 3;
		 }
		 console.log(c);
		 c(2);
		 
		 6.
		 var name = 'erdong';
		 (function () {
		     if (typeof name === 'undefined') {
		         var name = 'chen';
		         console.log(name);
		     } else {
		         console.log(name);
		     }
		 })();


		7.
		var a = 10;  
		function test() {  
		    a = 100;  
		    console.log(a);  
		    console.log(this.a);  
		    var a;  
		    console.log(a); 
		}
		test();  
		
		8.
		if (!('a' in window)) {
		    var a = 1;
		}
		console.log(a);
		
		9.
		var a = 1;
		
		function c(a, b) {
		    console.log(a);
		    a = 2;
		    console.log(a);
		}
		c();
		
		10.
		var val=1;
		var obj={
		    val:2,
		    del:function(){
		        console.log(this);                    
		        this.val*=2;
		        console.log(val);
		    }
		}
		
		obj.del();
		
		11.
		var name = "erdong";
		var object = {
		    name: "chen",
		    getNameFunc: function () {
		        return function () {
		            return this.name;
		        }
		    }
		}
		console.log(object.getNameFunc()());
		
		12.
		var name = "erdong";
		var object = {
		    name: "chen",
		    getNameFunc: function () {
		        var that = this;
		        return function () {
		            return that.name;
		        }
		    }
		}
		console.log(object.getNameFunc()());
		
		13.
		(function() {
		  var a = b = 3;
		})();
		console.log(typeof a === 'undefined');
		console.log(typeof b === 'undefined');
		
		14.
		console.log(typeof NaN === 'number');

		15.
		console.log(1 + "2" + "2");
		
		console.log(1 + +"2" + "2");
		
		console.log(1 + -"1" + "2");
		
		console.log(+"1" + "1" + "2"); 
		
		console.log( "A" - "B" + "2"); 
		
		console.log( "A" - "B" + 2); 
		
		16.
		var a = 666;
		console.log(++a);
		console.log(a++);
		console.log(a);
		
		17.
		console.log(typeof a);
		function a() {}
		var a;
		console.log(typeof a);
		
		18.
		var a;
		var b = 'undefined';
		console.log(typeof a);
		console.log(typeof b);
		console.log(typeof c);
		
		19.
		var x = 1;
		if(function f(){}){
		    x += typeof f;
		}
		console.log(x);
		
		20.
		var str = "123abc";
		console.log(typeof str++);
		
		21.
		console.log('b' + 'a' + +'a'+'a');

		22.
		var obj = {n: 1};
		function fn2(a) {
		    a.n = 2;
		}
		fn2(obj);
		console.log(obj.n);
		
		23.
		var x = 10;
		function fn() {
		    console.log(x);
		}
		function show(f) {
		    var x = 20;
		    f();
		}
		show(fn);
		
		24.
		function foo1() {
		    return {
		        bar: "hello"
		    };
		}
		function foo2() {
		    return 
		    {
		        bar: "hello"
		    };
		}
		console.log(foo1());
		console.log(foo2());
		
		25.
		console.log((function(){ return typeof arguments; })());
		
		26.
		console.log(0.1 + 0.2 == 0.3);
		 -->
	</body>
</html>